package com.grp6.game.model;

import java.util.ArrayList;
import java.util.List;

import com.grp6.game.common.IObserver;
import com.grp6.game.ui.platform.IActionListener;
import com.grp6.game.view.AbstractView;

public abstract class AbstractObservableModel<V extends AbstractView> implements IModel<V>, IActionListener{
	protected List<V> views = new ArrayList<V>();
	protected List<IObserver> observers = new ArrayList<IObserver>();

	@Override
	public List<IObserver> getObservers() {
		return observers;
	}

	@Override
	public void notifyObservers() {
		for(IObserver obs: observers)
			obs.update();
	}

	@Override
	public void addObservers(List<IObserver> observers) {
		this.observers.addAll(observers);
	}

	@Override
	public void removeObserver(List<IObserver> observers) {
		this.observers.removeAll(observers);
	}

	@Override
	public List<V> getViews() {
		return views;
	}

}
